<template>
  <s-layout
    title="我的"
    tabbar="/pages/index/user"
    navbar="user"
    :bgStyle="template.style?.background"
    onShareAppMessage
  >
   <view style="padding: 0 30rpx;margin-top: 130rpx;">
	  <!-- <view class="user_icon" @click="isTrue('/pages/index/userInfo/index')">
	   		<uni-icons type="gear-filled" color="#f8abbd" size="25"></uni-icons>
	   </view> -->
	   <view class="flex2">
		   <view class='flex1'  v-if="tokenShow==false">
			   <image class="userImage" :src="appuserInfo.avatar"></image>
			   	<view @click="loginFn"  class="pleaseLogin">请登录</view>
		   </view>
		   <view class='flex1'  v-if="tokenShow==true">
			   <image class="userImage" :src="appuserInfo.avatar"></image>
			   <view>
				   <view>{{appuserInfo.nickname}}</view>
				   <view class="flex1" >
						<image class="vipImage" src="../../static/vip.png" mode="widthFix"></image>
						<text class="vipImage_label">{{appuserInfo.szAgencyName}}</text>
				   </view>
			   </view>
		   </view>
		   <view class="  copy" v-if="tokenShow==true">
				<view class="code flex1"  @click="natTo('/pages/index/userInfo/qrcode')">
					<view>邀请码</view>
					<uni-icons type="right" size="15" color="#c6c6c6"></uni-icons>
				</view>
				<view class="flex1">
					<view>{{appuserInfo.invitationCode}}</view>
					<image @click="copyFn(appuserInfo.invitationCode)"  class="copy_image" src="../../static/copy.png" mode="widthFix"></image>
				</view>
		   </view>
	   </view>
	   <view class="flex2 show"  @click="isTrue('/pages/index/show')" >
		   <view>资产显示</view>
		   <view>{{appuserInfo.szWalletBalance}}</view>
	   </view>
	   <view class="grid_model">
		   <view class="flex_grid">
				   <view  class="grid" @click="isTrue('/pages/index/userInfo/reward')" >
					   <image class="icon_grid" src="../../static/recharge.png" ></image>
					   <view>充值</view>
				   </view>
		   		  
				   <view  class="grid" @click="isTrue('/pages/index/hedging')" >
					   <image class="icon_grid" src="../../static/balance.png"></image>
					   <view>余额互转</view>
				   </view>
				   <view  class="grid" @click="isTrue('/pages/index/reward')">
					   <image class="icon_grid" src="../../static/reward.png" style="border-radius: 50%;"></image>
					   <view>打赏</view>
				   </view>
				
				   <view  class="grid" @click="isTrue('/pages/index/userInfo/widthdraw')">
					   <image class="icon_grid" src="../../static/o.png" ></image>
					   <view>提现</view>
				   </view>
		   </view>
	   </view>
	   <view class="grid_model">
	   		<view class="flex_grid">
		<!-- 		<view  class="grid"  @click="isTrue('/pages/index/show')">
					   <image class="icon_grid" src="../../static/total.png"></image>
					   <view>总资产</view>
				</view> -->
				<view  class="grid" @click="isTrue('/pages/index/subordinate')" >
					   <image class="icon_grid" src="../../static/team.png"></image>
					   <view>团队</view>
				</view>
				<view  class="grid"  @click="noOpenFn">
					   <image class="icon_grid" src="../../static/train.png" ></image>
					   <view>直播培训</view>
				 </view>
				 <view  class="grid"   @click="noOpenFn">
					   <image class="icon_grid" src="../../static/customer.png"></image>
					   <view>客服中心</view>
				 </view>
				 <view  class="grid"  @click="noOpenFn" >
					   <image class="icon_grid" src="../../static/notice.png"></image>
					   <view>官方通知</view>
				 </view>
				 <view  class="grid"   @click="noOpenFn">
					   <image class="icon_grid" src="../../static/positioning.png"></image>
					   <view>地址管理</view>
				 </view>
				<view  class="grid" @click="isTrue('/pages/index/userInfo/index')" >
					   <image class="icon_grid" src="../../static/setting.png"></image>
					   <view>设置</view>
				</view>
				 <view  class="grid"  @click="isTrue('/pages/index/userInfo/switch')" >
					   <image class="icon_grid" src="../../static/qie.png"></image>
					   <view>切换账号</view>
				 </view>
				   <view  class="grid"  >
				   	   <image class="icon_grid" src="../../static/lianjie.png"></image>
				   	   <view>超级转链</view>
				   </view>
				 
			</view>
	  </view>
	  <!-- <view @click="wxpayFn">微信支付</view> -->
	  <view class="grid_model">
		   <view class="flex_grid">
			   <view  class="grid"  @click="noOpenFn" >
			   	   <image class="icon_grid" src="../../static/fensi.png"></image>
			   	   <view>粉丝</view>
			   </view>
			   <view  class="grid"  @click="noOpenFn" >
			   	   <image class="icon_grid" src="../../static/shoucang.png"></image>
			   	   <view>收藏夹</view>
			   </view>
			   <view  class="grid"  @click="noOpenFn" >
			   	   <image class="icon_grid" src="../../static/zuji.png"></image>
			   	   <view>足迹</view>
			   </view>
			   <view  class="grid"  @click="noOpenFn" >
			   	   <image class="icon_grid" src="../../static/gouwu.png"></image>
			   	   <view>购物车</view>
			   </view>
			   <view  class="grid"  @click="noOpenFn" >
			   	   <image class="icon_grid" src="../../static/bangzhu.png"></image>
			   	   <view>帮助中心</view>
			   </view>
			   <view  class="grid"  @click="noOpenFn" >
			   	   <image class="icon_grid" src="../../static/huodong.png"></image>
			   	   <view>运营管理</view>
			   </view>
			   <view  class="grid"   @click="noOpenFn">
			   	   <image class="icon_grid" src="../../static/xiaoxi.png"></image>
			   	   <view>消息中心</view>
			   </view>
			   <view  class="grid"  @click="noOpenFn" >
			   	   <image class="icon_grid" src="../../static/baobiao.png"></image>
			   	   <view>收益报表</view>
			   </view>
			   <view  class="grid"   @click="noOpenFn" >
			   	   <image class="icon_grid" src="../../static/yaoqin.png"></image>
			   	   <view>邀请</view>
			   </view>
			   <view  class="grid"  @click="noOpenFn" >
			   	   <image class="icon_grid" src="../../static/daogou.png"></image>
			   	   <view>个人导购</view>
			   </view>
			   <view  class="grid"  @click="noOpenFn" >
			   	   <image class="icon_grid" src="../../static/guanyu.png"></image>
			   	   <view>关于我们</view>
			   </view>
			   				
		   </view>
	  </view>
	   
	   
   </view>
    
  </s-layout>
</template>

<script setup>
  import { computed,ref } from 'vue';
  import { onShow, onPageScroll, onPullDownRefresh } from '@dcloudio/uni-app';
  import sheep from '@/sheep';

  // 隐藏原生tabBar
  uni.hideTabBar();

  const template = computed(() => sheep.$store('app').template.user);
  
  const appuserInfo=ref({});
  
  const tokenShow=ref(false)
  
  const paypassword=ref()
  
  const popup = ref(null);
 
  onShow(()=>{
	  if(uni.getStorageSync('token') ){
		 //  // appuserInfo.value=uni.getStorageSync('appuserInfo')
		   appuserInfo.value=sheep.$store('user').userInfo
		   tokenShow.value=true
		   console.log(appuserInfo.value);
		  
	  }else{
		   appuserInfo.value=sheep.$store('user').userInfo
		    tokenShow.value=false
	  }
	  
  })
  
  const wxpayFn=()=>{
	  // sheep.$api.login.wxpay({order_amt:0.1,goods_name:'11'}).then(res=>{
		 //  console.log(res);
			//   // window.location.href=res.data
			 
	  // })

  }
  
  const natTo=(url)=>{
	  uni.navigateTo({
	  	url:url
	  })
  }
  const noOpenFn=()=>{
	  uni.showToast({
		  title:'暂未开放',
		  icon:'none'
	  })
  }
  const isTrue=(item)=>{
	  console.log(item);
	  if(tokenShow.value){
		  console.log('1');
		  if(item=='/pages/index/hedging' || item=='/pages/index/userInfo/widthdraw'){
			  if(  appuserInfo.value.paymentPassword==0){
				  uni.navigateTo({
				  	url:'/pages/index/updatepaypassword'
				  })
			  }else{
				  natTo(item)
			  }
		  }else{
			  natTo(item)
		  }
	  }else{
		  console.log('2');
		  loginFn()
	  }
  }
  
  //点击赋值uni.setClipboardData
  const copyFn=(item)=>{
  	  uni.setClipboardData({
  		  data:item,
  		  success(res) {
  		  	console.log(res);
  		  }
  	  })
  }
  
  //跳转登录页面
  const loginFn=()=>{
  	  uni.navigateTo({
  	  	url:'/pages/index/loginpassword'
  	  })
  }
  

 
</script>

<style lang="scss" scoped>
	
	
	.show{
		padding:30rpx 20rpx;
		border-radius: 15rpx;
		margin-top: 50rpx;
		background-color: #fff;
	}
	.copy{
		color: #dcdcdc;
		.code{
			margin-right: 10rpx;
		}
	}
	.copy_image{
		width: 30rpx;
		margin: 0 20rpx;
	}
	.user_icon{
		display:flex;
		justify-content: flex-end;
		
		margin-right: 30rpx;
	}
	.flex1{
		display: flex;
		align-items: center;
	}
	.flex2{
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
	
	
	.userImage{
		width: 100rpx;
		height: 100rpx;
		margin-right: 20rpx;
	}
	.vipImage{
		width: 28rpx;
		margin-top: 10rpx;
	}
	
	.icon_grid{
		width: 66rpx;
		height: 66rpx;
		border-radius: 50%;
		
	}
	
	
	.grid_model{
		background-color: #fff;
		margin-top: 30rpx;
		border-radius: 15rpx;
		padding:20rpx 0;
	}
	.flex_grid{
		display: flex;
        flex-wrap: wrap;
	}
	.grid{
		width:25%;
		text-align: center;
		padding: 20rpx 0;
	}
</style>
